<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/6
 * Time: 16:12
 */

namespace app\admin\controller;
use app\admin\Controller;
use app\common\model\CarAuth as carModel;
\think\Loader::import('controller/Controller', \think\Config::get('traits_path'), EXT);

class CarAuth extends Controller
{
    use \app\admin\traits\controller\Controller;
    public function index () {

        if ($this->request->method() == "GET") {
            $keyword = $this->request->param('keyword');
            $where = [
                'ca.isdelete' => 0,
            ];

            $model = new carModel();

            $list = $model->getUserCarInfoList($where, "ca.*, ua.sex", $this->request, $keyword);


            $this->view->assign('list', $list);
            $this->view->assign("count", $list->total());
            $this->view->assign("page", $list->render());
            $this->view->assign('numPerPage', $list->listRows());
        }

        return $this->view->fetch();
    }

    public function detail () {

        if ($this->request->method() == "GET") {

            $id = $this->request->param("id");
            $where = [
                'ca.id' => $id,
                'ca.isdelete' => 0,
            ];

            $model = new carModel();
            $field = "ca.*, ua.nickname, ua.sex, ua.head";
            $data = $model->getUserCarInfo($where, $field);

            $this->view->assign('vo', $data);

        }

        return $this->view->fetch();
    }
}